<template>
  <div class="suitPeople-container">
    <van-nav-bar
      class="bgcolor"
      title="适宜人群"
      safe-area-inset-top
      @click-left="back"
    >
      <template #left>
        <van-icon class="leftIcon" name="arrow-left" size="18" />
      </template>
    </van-nav-bar>

    <van-tabs color="#ff8700" title-active-color="#ff8700" sticky>
      <van-tab
        v-for="personCate in personCateList"
        :title="personCate.name"
        :key="personCate.id"
      >
        <person-item :personCate="personCate.id" />
      </van-tab>
    </van-tabs>
  </div>
</template>

<script>
import PersonItem from "../personCate/personCateItem/index.vue";
import { getAllPersonCate } from "@/api/food";
export default {
  name: "PersonCate",
  components: { PersonItem },
  data() {
    return {
      personCateList: [],
    };
  },

  mounted() {
    this.getAllPersonCate();
  },

  methods: {
    back() {
      this.$router.go(-1);
    },

    getAllPersonCate() {
      getAllPersonCate().then((res) => {
        this.personCateList = res.data;
      });
    },
  },
};
</script>

<style lang="less" scoped>
.suitPeople-container {
  .bgcolor {
    background-color: #99d99d;
    color: #000;
    .leftIcon {
      color: #000;
    }
  }
}
</style>